<!--author:蒋鑫-->
<!--data:2021/3/4-->
<!--修改自己上传资源的信息-->
<form class="layui-form model-form" id="resource-form" lay-filter="resource-form">
    <input name="fileid" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label">资源名称</label>
        <div class="layui-input-block">
            <input class="layui-input" lay-verify="required" maxlength="20" name="finame"
                   readonly required type="text"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资源描述</label>
        <div class="layui-input-block">
            <textarea class="layui-input" id="fiinfo" lay-verify="required" name="fiinfo"
                      placeholder="简要介绍一下资源内容,适合人群等..." placeholder="请输入相关描述"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资源标签</label>
        <div class="layui-input-block">
               <input class="layui-input" id="fitags" lay-verify="required" name="fitags"
                         placeholder="请输入修改后的标签" placeholder="请输入相关描述"></input>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资源分类</label>
        <div class="layui-input-block">
            <select id="catgry" lay-verify="required" name="catgry">
                <option value="java">java</option>
                <option value="c">C语言</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">下载积分</label>
        <div class="layui-input-block">
            <input class="layui-input" id="points" max="5" min="0" name="points" type="number" value="0">
        </div>
    </div>
    <div class="layui-form-item model-form-footer">
        <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
        <button class="layui-btn" lay-filter="resource-form-submit" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'admin', 'form', 'xmSelect', 'formSelects'], function () {
        let layer = layui.layer;
        let admin = layui.admin;
        let form = layui.form;
        let xmSelect = layui.xmSelect;
        let formSelects = layui.formSelects;

        form.render('select');
        //回显user数据
        let resource = admin.getTempData('t_resources');
        form.val('resource-form', resource);


        // 表单提交事件
        form.on('submit(resource-form-submit)', function (data) {
            let res = data.field;
            admin.req('api-forum/resources/updateResource', JSON.stringify(res), function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg);
                    parent.layui.table.reload("resources-table");
                    admin.finishPopupCenter();
                } else {
                    layer.msg(data.msg);
                }
            }, 'POST');
            return false;
        });
    });
</script>